﻿using System.Collections.Generic;
using DomainModel;
using Repository.Abstract;

namespace Repository.NHibernate
{
    public class TimetableRepository : Repository<Timetable>, ITimetableRepository
    {
        public IEnumerable<Timetable> GetTimetablesByTeacherAndWeekAndDay(User teacher, int week, int day)
        {
            using (Session)
            {
                return Session.QueryOver<Timetable>().Where(t => t.Teacher == teacher && t.Week == week && t.Day == day).List<Timetable>();
            }
        }

        public IEnumerable<Timetable> GetTimetablesByGroupAndWeekAndDay(Group group, int week, int day)
        {
            using (Session)
            {
                return Session.QueryOver<Timetable>().Where(t => t.Group == group && t.Week == week && t.Day == day).List<Timetable>();
            }
        }

        public IEnumerable<Timetable> GetTimetablesBySubgroupAndWeekAndDay(Subgroup subgroup, int week, int day)
        {
            using (Session)
            {
                return Session.QueryOver<Timetable>().Where(t => t.Subgroup == subgroup && t.Week == week && t.Day == day).List<Timetable>();
            }
        }
    }
}